//
//  BrowseTableViewCell.m
//  ECO
//
//  Created by zl on 2019/10/12.
//  Copyright © 2019 谷银行. All rights reserved.
//

#import "BrowseTableViewCell.h"

@implementation BrowseTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
    }
    return self;
}
- (void)initwithDictionary:(NSDictionary *)dic{
    [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    NSArray *arr = @[@"全部订单",@"结算订单",@"待结算订单",@"退款订单"];
    NSMutableArray *arr1 = [[NSMutableArray alloc]initWithObjects:dic[@"totalAll"],dic[@"total3"],dic[@"total12"],dic[@"totalErr"], nil ];
    for (int i = 0; i<arr.count; i++) {
        // 背景按钮图片
        _GroudBtn = [[UIButton alloc]initWithFrame:CGRectMake(10+i%2*(kScreenWidth/2), 0+i/2*100, (kScreenWidth - 30)/2, 90)];
        [_GroudBtn setBackgroundImage:[UIImage imageNamed:@"背景-1"] forState:UIControlStateNormal];
        [_GroudBtn addTarget:self action:@selector(Button:) forControlEvents:UIControlEventTouchUpInside];
        _GroudBtn.tag = i;
        // 图片
        _imgV = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15, 25, 25)];
        _imgV.image = [UIImage imageNamed:arr[i]];
        // 标题
        _Title = [[UILabel alloc]initWithFrame:CGRectMake(45, 15, 100, 25)];
        _Title.text = arr[i];
        _Title.textColor = [UIColor colorWithHexString:@"#666666"];
        // 下一级图片
        _NextImg = [[UIImageView alloc]initWithFrame:CGRectMake(self.GroudBtn.frame.size.width - 12 -16, 20, 12, 12)];
        _NextImg.image = [UIImage imageNamed:@"背景-2"];
        // 个数
        _Num = [[UILabel alloc]initWithFrame:CGRectMake(20, 47, 100, 25)];
        if (arr1.count >0 ) {
            _Num.text = [NSString stringWithFormat:@"%@",arr1[i]];
        }else{
            _Num.text = @"0";
        }
        
        _Num.font = [UIFont systemFontOfSize:18];
        [self.GroudBtn addSubview:self.imgV];
        [self.GroudBtn addSubview:self.Title];
        [self.GroudBtn addSubview:self.NextImg];
        [self.GroudBtn addSubview:self.Num];
        [self.contentView addSubview:self.GroudBtn];
    }
}
- (void)Button:(UIButton *)send{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(BrowseTableViewCellClick:)]) {
        [self.delegate performSelector:@selector(BrowseTableViewCellClick:) withObject:[NSString stringWithFormat:@"%ld",send.tag]];
    }
}

@end
